<!doctype html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>软件测试项目管理系统-stpm v1.0</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="stylesheet" href="../../css/font.css">
    <link rel="stylesheet" href="../../css/xadmin.css">
    <link rel="stylesheet" type="text/css" href="../../lib/layui/css/login.css" />
    <!-- <link rel="stylesheet" href="./css/theme5.css"> -->
    <script src="../../lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../../js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <script>
        // 是否开启刷新记忆tab功能
        var is_remember = false;
    </script>
</head>
<body class="index">
<!-- 顶部开始 -->
<div class="container">
    <div class="logo">
        <a href="../index.html">stpm v1.0</a></div>
    <div class="left_open">
        <a><i title="折叠/展开" class="iconfont">&#xe699;</i></a>
    </div>
    <ul class="layui-nav left fast-add" lay-filter="">
        <li class="layui-nav-item">
            <a href="../index.html">我的</a>
        </li>
        <li class="layui-nav-item">
            <a href="../project/project-index.html">项目</a>
        </li>
        <li class="layui-nav-item">
            <a href="../develop/develop-index.html">开发</a>
        </li>
        <li class="layui-nav-item">
            <a href="../test/test-index.html">测试</a>
        </li>
        <li class="layui-nav-item">
            <a href="../word/word-index.html">文档</a>
        </li>
        <li class="layui-nav-item layui-this">
            <a href="statistic-index.html">统计</a>
        </li>
    </ul>
    <ul class="layui-nav right" lay-filter="">
        <li class="layui-nav-item">
            <a href=""><img src="https://t.cn/RCzsdCq" class="layui-nav-img">我</a>
            <dl class="layui-nav-child">
                <!-- 二级菜单 -->
                <dd>
                    <a onclick="layer.open({
                            type: 1,
                            title: '个人资料',
                            area: ['600px', '500px'],
                            content: $('#username_edit')
                        });"><i class="layui-icon layui-icon-user"></i>个人资料</a>
                </dd>
                <dd>
                    <a onclick="layer.open({
                            type: 1,
                            title: '修改密码',
                            area: ['600px', '500px'],
                            content: $('#password_edit')
                        });"><i class="layui-icon layui-icon-password"></i>修改密码</a>
                </dd>
                <hr />
                <dd>
                    <a class="loginout" href="../login.html"><i class="layui-icon layui-icon-close"></i>切换账号</a>
                </dd>
                <dd>
                    <a class="loginout" href="javascript:;" onclick="logout()"><i class="layui-icon layui-icon-close"></i>退出</a>
                </dd>
            </dl>
        </li>
    </ul>
</div>
<!-- 顶部结束 -->
<!-- 中部开始 -->
<!-- 左侧菜单开始 -->
<div class="left-nav">
    <div id="side-nav">
        <ul id="nav">
            <li class="sub-menu">
                <a onclick="xadmin.add_tab('开发','./statistic-develop.html')">
                    <i class="layui-icon layui-icon-fire"></i>
                    <cite>开发</cite>
                    <i class="layui-icon layui-icon-right nav_right"></i>
                </a>
            </li>
            <li class="sub-menu">
                <a onclick="xadmin.add_tab('测试','./statistic-test.html')">
                    <i class="layui-icon layui-icon-flag"></i>
                    <cite>测试</cite>
                    <i class="layui-icon layui-icon-right nav_right"></i>
                </a>
            </li>
        </ul>
    </div>
</div>
<!-- <div class="x-slide_left"></div> -->
<!-- 左侧菜单结束 -->
<!-- 右侧主体开始 -->
<div class="page-content">
    <div class="layui-tab tab" lay-filter="xbs_tab" lay-allowclose="false">
        <ul class="layui-tab-title">
            <li class="home">
                <i class="layui-icon">&#xe68e;</i>首页
            </li>
        </ul>
        <div class="layui-unselect layui-form-select layui-form-selected" id="tab_right">
            <dl>
                <dd data-type="this">关闭当前</dd>
                <dd data-type="other">关闭其它</dd>
                <dd data-type="all">关闭全部</dd>
            </dl>
        </div>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
                <iframe src='statistic-project.html' frameborder="0" scrolling="yes" class="x-iframe"></iframe>
            </div>
        </div>
        <div id="tab_show"></div>
    </div>
</div>
<div class="page-content-bg"></div>
<style id="theme_style"></style>
<!-- 右侧主体结束 -->
<!-- 中部结束 -->
<!-- 底部开始 -->
<!--<div class="footer">-->
<!--<div class="copyright">Copyright ©2019 stpm v1.0 All Rights Reserved</div>-->
<!--</div>-->
<!-- 底部结束 -->
<!--百度统计可去掉-->
<script type="text/javascript">
    layui.use(['form','layer'],function () {
        var form=layui.form;
        var $=layui.jquery;
        var layer=layui.layer;
        $.ajax({
            type:"GET",
            url:"http://localhost:8080/user/get",
            xhrFields:{withCredentials:true},
            success:function(data){
                if(data.status=="success"){
                    $("#username").val(data.data.username);
                    $("#usernameText").val(data.data.username);
                    $("#role").val(data.data.role);
                    $("#realname").val(data.data.realname);
                }else{
                    layer.msg(data.data.errMsg, {
                        icon: 5,
                        time:2000
                    });
                }
            },
            error:function(data){
                layer.msg(data.data.errMsg, {
                    icon: 5,
                    time:2000
                });
            },
        });

        form.on("submit(update_username)",function (obj) {
            //获取表单数据
            var field = obj.field;
            $.ajax({
                url: 'http://localhost:8080/user/update-realname',
                data: field,
                contentType: "application/x-www-form-urlencoded",
                type: 'POST',
                xhrFields: {
                    withCredentials: true
                },
                success: function(data) {
                    if(data.status == "success") {
                        layer.msg('修改姓名成功', {
                            icon: 1,
                            time: 2000
                        }, function() {
                            layer.closeAll();
                        });
                    } else {
                        layer.msg(data.data.errMsg, {
                            icon: 5,
                            time:2000
                        });
                    }
                }
            });
            return false;
        });
        form.on("submit(update_password)",function (obj) {
            //获取表单数据
            var field = obj.field;
            //验证两次密码是否相同
            if($("#newPassword").val() != $("#confirmPassword").val()) {
                layer.msg('两次密码不一致', {
                    icon: 5,
                    time: 1000
                });
                return false;
            }
            $.ajax({
                url: 'http://localhost:8080/user/update-password',
                data: field,
                contentType: "application/x-www-form-urlencoded",
                type: 'POST',
                xhrFields: {
                    withCredentials: true
                },
                success: function(data) {
                    if(data.status == "success") {
                        layer.msg('修改密码成功', {
                            icon: 1,
                            time: 2000
                        }, function() {
                            //添加用户成功后关闭弹窗并刷新
                            layer.closeAll();
                        });
                    } else {
                        layer.msg(data.data.errMsg, {
                            icon: 5,
                            time:2000
                        });
                    }
                }
            });
            return false;
        });
    });
    function logout() {
        $.ajax({
            url: 'http://localhost:8080/user/logout',
            contentType: "application/x-www-form-urlencoded",
            type: 'POST',
            xhrFields: {
                withCredentials: true
            },
            success: function(data) {
                if(data.status == "success") {
                    layer.msg('注销成功', {
                        icon: 1,
                        time: 1000
                    }, function() {
                        //登录后不可再返回登录页
                        window.location.replace('../login.html');
                    });
                } else {
                    layer.msg(data.data.errMsg, {
                        icon: 5,
                        time:1000
                    });
                }
            },
            error: function(xhr) {
                console.log('error');
                console.log(xhr);
                layer.msg('请按F12查看控制台信息', {
                    icon: 5,
                    time:1000
                });
            }
        });
    };
</script>
</body>
<div class="login-wrapper" style="background-color: lightgray;display: none" id="username_edit">
    <div class="login-body">
        <div class="layui-card">
            <div class="layui-card-header">
                个人资料
            </div>
            <div class="layui-card-body layui-form layui-form-pane"  style="width: 300px">
                <!--用户名-->
                <div class="layui-form-item">
                    <label class="layui-form-label"><i class="layui-icon layui-icon-username"></i></label>
                    <div class="layui-input-inline">
                        <input name="username" id="username" type="text" autocomplete="off" placeholder="用户名" class="layui-input" disabled>
                    </div>
                    <div class="layui-form-mid" style="color: red;">*</div>
                </div>
                <!--姓名-->
                <div class="layui-form-item">
                    <label class="layui-form-label"><i class="layui-icon layui-icon-username"></i></label>
                    <div class="layui-input-inline">
                        <input name="realname" id="realname" type="text" required lay-verify="required" autocomplete="off" placeholder="姓名" class="layui-input">
                    </div>
                    <div class="layui-form-mid" style="color: red;">*</div>
                </div>
                <!--当前角色-->
                <div class="layui-form-item">
                    <label class="layui-form-label"><i class="layui-icon layui-icon-note"></i></label>
                    <div class="layui-input-inline">
                        <input name="role" id="role" type="text" autocomplete="off" placeholder="当前角色" class="layui-input" disabled>
                    </div>
                    <div class="layui-form-mid" style="color: red;">*</div>
                </div>
                <!--提交注册-->
                <div class="layui-form-item">
                    <button lay-filter="update_username" class="layui-btn layui-btn-fluid layui-btn-radius" lay-submit>立即提交</button>
                </div>
            </div>
        </div>
    </div>
    <div class="login-footer">
        <p>© 2019 </p>
    </div>
</div>
<div class="login-wrapper" style="background-color: lightgray;display: none" id="password_edit">
    <div class="login-body">
        <div class="layui-card">
            <div class="layui-card-header">
                修改密码
            </div>
            <div class="layui-card-body layui-form layui-form-pane"  style="width: 300px">
                <!--用户名-->
                <div class="layui-form-item" style="display: none">
                    <label class="layui-form-label"><i class="layui-icon layui-icon-username"></i></label>
                    <div class="layui-input-inline">
                        <input name="usernameText" id="usernameText" type="text" autocomplete="off" placeholder="用户名" class="layui-input" disabled>
                    </div>
                    <div class="layui-form-mid" style="color: red;">*</div>
                </div>
                <!--密码-->
                <div class="layui-form-item">
                    <label class="layui-form-label"><i class="layui-icon layui-icon-password"></i></label>
                    <div class="layui-input-inline">
                        <input id="oldPassword" name="oldPassword" type="password" required lay-verify="required" autocomplete="off" placeholder="原密码" class="layui-input">
                    </div>
                    <div class="layui-form-mid" style="color: red;">*</div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><i class="layui-icon layui-icon-password"></i></label>
                    <div class="layui-input-inline">
                        <input id="newPassword" name="newPassword" type="password" required lay-verify="required" autocomplete="off" placeholder="密码" class="layui-input">
                    </div>
                    <div class="layui-form-mid" style="color: red;">*</div>
                </div>
                <!--确认密码-->
                <div class="layui-form-item">
                    <label class="layui-form-label"><i class="layui-icon layui-icon-password"></i></label>
                    <div class="layui-input-inline">
                        <input id="confirmPassword" name="confirmPassword" type="password" required lay-verify="required" autocomplete="off" placeholder="确认密码" class="layui-input">
                    </div>
                    <div class="layui-form-mid" style="color: red;">*</div>
                </div>
                <!--提交注册-->
                <div class="layui-form-item">
                    <button lay-filter="update_password" class="layui-btn layui-btn-fluid layui-btn-radius" lay-submit>立即提交</button>
                </div>
            </div>
        </div>
    </div>
    <div class="login-footer">
        <p>© 2019 </p>
    </div>
</div>
</html>